﻿using System.Linq;
using System.Web.Mvc;
using StructureMap;

namespace WS.EKA.DI
{
    public static class Bootstrapper
    {
        public static void ConfigureStructureMap()
        {
            //ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
            DependencyResolver.SetResolver(
                t =>
                {
                    try { return ObjectFactory.GetInstance(t); }
                    catch { return null; }
                },
                t => ObjectFactory.GetAllInstances<object>().Where(s => s.GetType() == t)
            );

            ObjectFactory.Configure(x =>
            {
                x.AddRegistry(new ServiceRegistry());
            });
        }
    }
}
